package com.zhangyongyi.carhome.adapter.recommend.newes;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zhangyongyi.carhome.entity.greendao.FocusimgList;
import com.zhangyongyi.carhome.fragment.recommend.newest.FocusingFragment;

import java.util.List;


/**
 * Created by dllo on 16/1/11.
 * 轮播图的适配器
 */
public class NewestViewPagerAdapter extends FragmentPagerAdapter {
    private List<FocusimgList> focusimgLists;


    public void addData(List<FocusimgList> datas){
        focusimgLists = datas;
        notifyDataSetChanged();
    }

    public NewestViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        FocusimgList f = focusimgLists.get(position);
        String imgurl = f.getImgurl();

        return FocusingFragment.getInstance(imgurl);

    }

    @Override
    public int getCount() {
        return focusimgLists != null && focusimgLists.size() > 0 ? focusimgLists.size() : 0;
    }
}
